package Mydwei;

import org.omg.PortableInterceptor.INACTIVE;

import java.util.Comparator;
import java.util.PriorityQueue;

class Student implements Comparable<Student>{
    int age;

    public Student(int age) {
        this.age = age;
    }

    @Override
    public String toString() {
        return "Student{" +
                "age=" + age +
                '}';
    }

    @Override
    public int compareTo(Student o) {
        return o.age-this.age;
    }
}
public class Test {
    public static void main(String[] args) {
       /* int arr[]={1,2,3,4,5,6,7,8,9,10};
        DW dw=new DW();
        dw.create(arr);
        dw.push(11);
        dw.pollhead();
        System.out.println(dw.peekhead());
      System.out.println();*/

        PriorityQueue<Integer>priorityQueue=new PriorityQueue<>(new Comparator<Integer>() {//传参型的向上转型，继承与接口实质也还是向上转型

            @Override
            public int compare(Integer o1, Integer o2) {
                return o2-o1;
            }
        });//PriorityQueue就是优先级队列就是堆，一开始默认小堆;
        priorityQueue.offer(1);
        priorityQueue.offer(2);
        priorityQueue.offer(3);
        priorityQueue.poll();
        priorityQueue.peek();
       /* priorityQueue.offer(new Student(12));
        priorityQueue.offer(new Student(10));
        priorityQueue.offer(new Student(11));
        priorityQueue.offer(new Student(17));
        System.out.println(priorityQueue);*/
    }
}